package com.wkk.rabbitmq;

import java.util.Date;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 发送者
 * 
 * @author admin
 *
 */
@Component
public class Sender {
	@Autowired
	private AmqpTemplate rabbitTemplate;

	public void send() {
		String msg = "hello" + new Date();
		while (true) {
			try {
				Thread.sleep(1000);
				this.rabbitTemplate.convertAndSend("wkk", msg);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}

		}

	}

}
